package fy.bpm;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.fy.oa.zc.domain.FySummaryView;
import com.fy.oa.zc.manager.AFyOA_FormEventManager;
import com.fy.oa.zc.manager.FyOA_FormEventManager;
import com.seeyon.ctp.menu.check.UserMenuCheck;
import com.soa.eis.adapter.framework.message.IMsgObject;
import com.soa.eis.adapter.framework.message.impl.GroupRecord;
import com.soa.eis.adapter.framework.message.impl.MsgObject;
import com.soa.eis.adapter.framework.requester.IServiceRequester;
import com.soa.eis.adapter.framework.requester.impl.BaseServiceRequester;

import fy.mdm.dao.FiexdAssetReviewDao;
import fy.mdm.dao.MaterialRequestNoTimerTask;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class BPMPricingApproval  extends AFyOA_FormEventManager implements FyOA_FormEventManager {
	public String toString() {
		return "IT项目立项审批表";
	}
	private static Log log = LogFactory.getLog(FiexdAssetReviewDao.class);
	@Override
	public String dealProcessEvent(FySummaryView view, long affairid) {
	System.out.println("dealProcessEvent");
		log.info("yanch dealProcessEvent ");
		return view.toString();
	}

	@Override
	public String dealFinishEvent(FySummaryView view) {
		System.out.println("dealFinishEvent");
		System.out.println("结束");
		log.info("yanch dealFinishEvent ");
		return view.toString();
	}

	@Override
	public String dealStopEvent(FySummaryView view) {
		System.out.println("dealStopEvent");
		log.info("yanch dealStopEvent ");
		return view.toString();
	}

	@Override
	public String dealCancelEvent(FySummaryView view, long userid, String message) {
		System.out.println("dealCancelEvent");
		log.info("yanch dealCancelEvent ");
		return view.toString();
	}

	@Override
	public String dealStepBackEvent(FySummaryView view) {
		System.out.println("dealStepBackEvent");
		log.info("yanch dealStepBackEvent ");
		return view.toString();
	}
	
	
	public boolean StateReturn(String flowID,String flowState) throws Exception {
		try {
				IServiceRequester Requester = BaseServiceRequester.getInstance();
				// 定义请求报文对象
			log.info("yanch StateReturn");
				IMsgObject reqMo = new MsgObject(IMsgObject.MOType.initSR);
				String SourceSysID = "06004"; // 请求方(发布方)
				String ServiceID = "02007000000008";// 响应方(发布方)
				// 获取系统时间
				Date date = new Date();
				SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
				String format = simpleDateFormat.format(date);
				// 对请求报文对象进行设置
				reqMo.setSourceSysID(SourceSysID); // 设置报文 请求方系统号
				reqMo.setSerialNO(format.substring(0, 8) + SourceSysID
						+ String.format("%06d", ++MaterialRequestNoTimerTask.requestNo));// 设置报文流水号,第三段表示今天发送的第几的一次报文
				reqMo.setServiceID(ServiceID); // 设置报文 提供方服务号
				reqMo.setServiceDateTime(format); // 设置报文 日期时间
				reqMo.setReqValue("FLOW_ID",flowID);
				reqMo.setReqValue("FLOW_STATE",flowState);
				System.out.println("111111111"+reqMo);
				log.info("reqMo="+reqMo);
				IMsgObject respMo = null;
				respMo = Requester.execute(reqMo);
				System.out.println("~~~~~~~~~~~~~~~" + respMo);
			    log.info("respMo="+respMo);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return true;
	}

}
